package net.wanho.shiro.matcher;

import net.wanho.util.JwtUtils;
import org.apache.shiro.authc.AuthenticationInfo;
import org.apache.shiro.authc.AuthenticationToken;
import org.apache.shiro.authc.credential.SimpleCredentialsMatcher;

/**
 * Author：汤小洋
 * Date：2023-08-25 14:22
 * Description：Jwt凭证匹配器
 */
public class JwtMatcher extends SimpleCredentialsMatcher {

    @Override
    public boolean doCredentialsMatch(AuthenticationToken jwtToken, AuthenticationInfo info) {
        String token = (String) jwtToken.getPrincipal();
        // 判断token是否有效
        return JwtUtils.valid(token);
    }
}
